package com.jdkreader.concurrency.queue;


public class Butterer implements Runnable{

    private ToastQueue dryQueue,buitteredQueue;

    public Butterer(ToastQueue dry,ToastQueue butter){
        dryQueue = dry;
        buitteredQueue = butter;
    }

    @Override
    public void run(){
        try{
            //使用队列给吐司摸酱
            while(!Thread.interrupted()){
                Toast t= dryQueue.take();
                t.butter();
                System.out.println(t+" buttered");
                buitteredQueue.put(t);
            }
        }catch(InterruptedException e){
            e.printStackTrace();
        }

        System.out.println("Butterer off");
    }

}
